local newt = reload("newt")
local delt = reload("delt")
local ifTable = reload("ifTable")
local ifString = reload("ifString")

local function localf(bson)
    if not ifTable(bson) then
        return bson
    end
    local keys = newt()
    for k, v in pairs(bson) do
        if ifTable(v) then
            localf(v)
        elseif v == "true" then
            bson[k] = true
        elseif v == "false" then
            bson[k] = false
        end
        if ifString(k) then
            table.insert(keys, k)
        end
    end

    ---将可以转换为数字的字符串键转换为数字
    for _, k in ipairs(keys) do
        local num = tonumber(k)
        if num then 
            local v = bson[k]
            bson[k] = nil
            bson[num] = v
        end
    end
    delt(keys)
    return bson
end

return localf
